home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / kiss-0.11 / kiss-0 / kiss / src / dormdir.c < prev    next >
C/C++ Source or Header  |  1995-03-23  |  726b  |  31 lines

  1. #include "kiss.h"
  2.  
  3. int dormdir (Stringstack s)
  4. {
  5.     register int
  6.     ret = 0,
  7.     i;
  8.     struct stat
  9.     statbuf;
  10.  
  11.     if (getopt (s.nstr, s.str, "h") != -1 || s.nstr < 2)
  12.     error ("Bad commandline.\n"
  13.            "Usage: %s [-h] directory(~ies)\n"
  14.            "Where:\n"
  15.            "    -h: this text\n"
  16.            "    directories: directories to remove, which must be empty\n"
  17.            , progname);
  18.  
  19.     for (i = 1; i < s.nstr; i++)
  20.     {
  21.     if (stat (s.str [i], &statbuf))
  22.         ret += warning ("cannot stat \"%s\"", s.str [i]);
  23.     else if (! S_ISDIR (statbuf.st_mode))
  24.         ret += warning ("\"%s\" is no directory", s.str [i]);
  25.     else if (rmdir (s.str [i]))
  26.         ret += warning ("problem while removing \"%s\"", s.str [i]);
  27.     }
  28.  
  29.     return (ret);
  30. }
  31.